package com.google.code.p.restrpc.core.registry;

/**
 * @author dz
 */
public interface RegistryClient {
    
    /**
     * @param address
     * @param port
     * @return
     */
    public boolean isRegistered(String address, int port);
    
    /**
     * Get the status of current node on directory service center.
     * 
     * @param address
     * @param port
     * @return the status of the service node registered in register directory
     * <ol>
     * <li>online : the service node is online</li>
     * <li>offline : the service node is offline and need to activiate</li>
     * <li>unknown : it indicates the network is not available or the register directory is not available</li>
     * </ol>
     */
    public String getStatus(String address, int port);
    
    /**
     * The server node may be set to unavailable by directory service center if
     * the network is detected as broken. When the network is available,the
     * server node should notify the center to active itself.
     * 
     * @param address
     * @param port
     * @return
     */
    public void activate(String address, int port);
    
    /**
     * Before the server node shut-down, should unregister all registered-entry
     * in directory service center.
     * 
     * @param address
     * @param port
     */
    public void unregisterAll(String address, int port);
    
    /**
     * @param address
     * @param port
     * @param weight
     *            the weight of the server node
     */
    public void registerNode(String address, int port, int weight);
    
    /**
     * @param serviceName
     * @param url
     * @param weight
     *            the weight of the server node
     */
    public void registerService(String serviceName, String url, int weight);
    
    /**
     * @param serviceName
     * @param url
     * @param weight
     */
    public void unregisterService(String serviceName, String url);
    
}
